<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 2008 05:00:00 GMT");

//Safari需要1024个字节
//IE需要256字节
$i = 0;
while($i < 1024)
{
	echo " ";
	$i ++;
}
echo "<br />";//兼容Opera、Safari,有html标签才会输出

?>

<?php
	
	
	$fname = "clientids";
	$cn = getContent($fname);


	/*$fh = fopen($fname, "w+");
	fwrite($fh, $cn + 1);
	fclose($fh);
	*/
	file_put_contents($fname, $cn + 1);

	session_start();
	$ccc = file_get_contents($fname);
	echo "si:".session_id();
	flush();
	
	set_time_limit(0);
	while(1) 
	{
		echo $ccc."<br />";


		ob_flush();
		flush(); // used to send the echoed data to the client
		sleep(1); // a little break to unload the server CPU
	}


	function getContent($fname)
	{
		$fsize = filesize($fname);
		if($fsize < 1)
		{
			$rcn = 0;
		}
		else
		{
			$rcn = intval(file_get_contents($fname));
		}
		
		return $rcn;
	}
?>
